package com.imporven.sell.convert;

import com.imporven.sell.domain.OrderMaster;
import com.imporven.sell.dto.OrderDTO;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author imporven
 * @version 1.0.0
 * @date 2018-7-15 21:59
 * 订单主domain->dto转换器
 */
public class OrderMaster2OrderDTOConvert {

    public static List<OrderDTO> convert(List<OrderMaster> orderMasterList) {
        return orderMasterList.stream()
                    .map(orderMaster -> convert(orderMaster))
                    .collect(Collectors.toList());
    }

    public static OrderDTO convert(OrderMaster orderMaster) {
        OrderDTO orderDTO = new OrderDTO();
        BeanUtils.copyProperties(orderMaster,orderDTO);
        return orderDTO;
    }
}
